﻿using Zen4SyncOrchestrator;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Zen4SyncPOCO.POCO.SQLServerExecution;
using Zen4SyncModel;
using Zen4SyncPOCO.POCO.MergeSync;
using Zen4SyncPOCO.POCO.SQLCEExecution;
using Zen4SyncPOCO.POCO.Admin;
using System.Data.Objects.DataClasses;
using System.Collections.Generic;
using Zen4SyncPOCO.POCO.Scenario;
using Zen4SyncPOCO.POCO.MEF;
using Zen4SyncPOCO.POCO.SQLCEBackup;
using Zen4SyncPOCO.Enum.MergeSync;
using Zen4SyncPOCO.Enum.Admin;
using System.Text;
using System.Linq;
using System.Data.SqlClient;

namespace Zen4SyncOrchestrator.Test
{


    /// <summary>
    ///Classe de test pour ModelConverterTest, destinée à contenir tous
    ///les tests unitaires ModelConverterTest
    ///</summary>
    [TestClass()]
    public class ModelConverterTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Obtient ou définit le contexte de test qui fournit
        ///des informations sur la série de tests active ainsi que ses fonctionnalités.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

       
        [ClassInitialize()]
        public static void MyClassInitialize( TestContext testContext )
        {
            using ( Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities() )
            {
                z4sEntities.sp_z4s_purge_database( true );
                z4sEntities.sp_z4s_insert_reference_data();
                z4sEntities.sp_z4s_create_encryption_key( "Password34!" );
                z4sEntities.sp_z4s_insert_test_data_Orchestrator();

            }
        }

        [ClassCleanup()]
        public static void MyClassCleanup()
        {
            using(Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities())
            {
                z4sEntities.sp_z4s_purge_database( true );
            }

            using(SqlConnection sqlConnection = new SqlConnection( @"Server=localhost\SQL2008R2;Database=Zen4SyncRepository; Trusted_Connection=yes;" ))
            {
                
                SqlCommand sqlCommand = new SqlCommand("DROP Symmetric Key Zen4SyncSymmetricKey", sqlConnection);
                sqlConnection.Open();
                sqlCommand.ExecuteNonQuery();
                sqlConnection.Close();
            }
        }

        private testScenario GetTestScenario( Guid testScenarioId )
        {
            using ( Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities() )
            {
                testScenario z4sTestScenario = z4sEntities.testScenario.Include( "activity" ).Where( t => t.testScenario_id == testScenarioId ).SingleOrDefault();
                return z4sTestScenario;
            }
        }


        private clientSession GetClientSession( Guid clientSessionId )
        {
            using ( Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities() )
            {
                clientSession z4sClientSession = z4sEntities.clientSession.Include( "testScenario" ).Include( "testScenario.activity" ).Include( "activityContext" ).Where( c => c.clientSession_id == clientSessionId ).SingleOrDefault();
                return z4sClientSession;
            }

        }

        private string SymmetricKeyPassword { get { return "Password34!"; } }
    

        /// <summary>
        ///Test pour POCOSqlServerExecution
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSqlServerExecutionTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlServerExecutionId = new Guid( "E4782372-3F36-4468-9571-DE3E808932DB" );
            SqlServerExecution expected = new SqlServerExecution()
            {
                sqlServerExecution_id = sqlServerExecutionId,
                sqlServerExecution_sqlQuery = "sqlServerExecutionSqlQuery",
            };
            SqlServerExecution actual;
            actual = target.POCOSqlServerExecution( sqlServerExecutionId );
            Assert.AreEqual( expected.sqlServerExecution_id, actual.sqlServerExecution_id );
            Assert.AreEqual( expected.sqlServerExecution_sqlQuery, actual.sqlServerExecution_sqlQuery );
        }
       
        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCODistributorTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            distributor z4sDistributor = target.z4sEntityProvider.GetSyncSession( new Guid( "2B2BE227-2C90-42F8-9332-B3219C848B97" ) ).distributor;
            Distributor expected = new Distributor()
            {
                distributor_id = new Guid( "5F193191-68EB-485D-88A3-16D81A133CEB" ),
                distributor_name = "<distributor_name, nvarchar(255),>",
                distributor_address = "<distributor_address, nvarchar(2000),>",
                distributor_login = null,
                distributor_password = "password distributor",
                distributor_networkTypeEnum = NetworkTypeEnum.DefaultNetwork,
                distributor_securityTypeEnum = SecurityTypeEnum.NTAuthentication,
                distributor_profileName = "DEFAULT"
            };
            Distributor actual;
            actual = target.ConvertToPOCO(z4sDistributor, SymmetricKeyPassword);
            Assert.AreEqual( expected.distributor_id, actual.distributor_id );
            Assert.AreEqual( expected.distributor_name, actual.distributor_name );
            Assert.AreEqual( expected.distributor_address, actual.distributor_address );
            Assert.AreEqual( expected.distributor_login, actual.distributor_login );
            Assert.AreEqual( expected.distributor_password, actual.distributor_password );
            Assert.AreEqual( expected.distributor_networkTypeEnum, actual.distributor_networkTypeEnum );
            Assert.AreEqual( expected.distributor_securityTypeEnum, actual.distributor_securityTypeEnum );
            Assert.AreEqual( expected.distributor_profileName, actual.distributor_profileName );
        }
 
        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOPublisherTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            publisher z4sPublisher = target.z4sEntityProvider.GetSyncSession( new Guid( "2B2BE227-2C90-42F8-9332-B3219C848B97" ) ).publisher;
            Publisher expected = new Publisher()
            { 
                publisher_id = new Guid( "05C54B7E-65FE-403F-88ED-F35AA7194ED6" ),
                publisher_name = "publisher_name",
                publisher_address = "publisher_address",
                publisher_database = "publisher_database",
                publisher_login = null,
                publisher_password = "password publisher",
                publisher_networkTypeEnum = NetworkTypeEnum.DefaultNetwork,
                publisher_securityTypeEnum = SecurityTypeEnum.NTAuthentication,
            };
            Publisher actual;
            actual = target.ConvertToPOCO( z4sPublisher, SymmetricKeyPassword );
            Assert.AreEqual( expected.publisher_id, actual.publisher_id );
            Assert.AreEqual( expected.publisher_name, actual.publisher_name );
            Assert.AreEqual( expected.publisher_address, actual.publisher_address );
            Assert.AreEqual( expected.publisher_database, actual.publisher_database );
            Assert.AreEqual( expected.publisher_login, actual.publisher_login );
            Assert.AreEqual( expected.publisher_password, actual.publisher_password );
            Assert.AreEqual( expected.publisher_networkTypeEnum, actual.publisher_networkTypeEnum );
            Assert.AreEqual( expected.publisher_securityTypeEnum, actual.publisher_securityTypeEnum );
        }                              
         
        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOInternetTest()
        {   
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            internet z4sInternet = target.z4sEntityProvider.GetSyncSession( new Guid( "2B2BE227-2C90-42F8-9332-B3219C848B97" ) ).internet;
            Internet expected = new Internet()
            {
                internet_id = new Guid( "00C47ABE-01F3-4D6E-A39D-97B0B2620ABE" ),
                internet_name = "internet_name",
                internet_url = "internet_url",
                internet_login = null,
                internet_password = "password internet",
                internet_proxyLogin = null,
                internet_proxyPassword = "password internet proxy",
                internet_proxyServer = null
            };
            Internet actual;
            actual = target.ConvertToPOCO( z4sInternet,SymmetricKeyPassword );
            Assert.AreEqual( expected.internet_id, actual.internet_id );
            Assert.AreEqual( expected.internet_url, actual.internet_url );
            Assert.AreEqual( expected.internet_name, actual.internet_name );
            Assert.AreEqual( expected.internet_login, actual.internet_login );
            Assert.AreEqual( expected.internet_password, actual.internet_password );
            Assert.AreEqual( expected.internet_proxyLogin, actual.internet_proxyLogin );
            Assert.AreEqual( expected.internet_proxyPassword, actual.internet_proxyPassword );
            Assert.AreEqual( expected.internet_proxyServer, actual.internet_proxyServer );
        }
               
        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOSubscriberTest()
        {

            ModelConverter_Accessor target = new ModelConverter_Accessor();
            subscriber z4sSubscriber = target.z4sEntityProvider.GetSyncSessionContext( new Guid( "823A1687-11B0-426F-BD08-0827B4AFD64D" ) ).subscriber;
            Subscriber expected = new Subscriber()
            {
                subscriber_id = new Guid( "C25573CB-1D1F-458A-88F4-AB4AB4F952B9" ),
                subscriber_name = "subscriber_name",
                subscriber_hostName = "subscriber_hostName",
                subscriber_connectionString = "subscriber_connectionString",
                subscriber_deleteSdfIfItExists = true,
                subscriber_sdfFileName = "subscriber_sdfFileName",
                subscriber_sdfFileDirectory = "subscriber_sdfFileDirectory",
                subscriber_validateTypeEnum = ValidateTypeEnum.NoValidation
            };
            Subscriber actual;
            actual = target.ConvertToPOCO( z4sSubscriber );
            Assert.AreEqual( expected.subscriber_id, actual.subscriber_id );
            Assert.AreEqual( expected.subscriber_name, actual.subscriber_name );
            Assert.AreEqual( expected.subscriber_hostName, actual.subscriber_hostName );
            Assert.AreEqual( expected.subscriber_connectionString, actual.subscriber_connectionString );
            Assert.AreEqual( expected.subscriber_deleteSdfIfItExists, actual.subscriber_deleteSdfIfItExists );
            Assert.AreEqual( expected.subscriber_sdfFileName, actual.subscriber_sdfFileName );
            Assert.AreEqual( expected.subscriber_sdfFileDirectory, actual.subscriber_sdfFileDirectory );
            Assert.AreEqual( expected.subscriber_validateTypeEnum, actual.subscriber_validateTypeEnum );
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOSqlceCheckDataParametersTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            EntityCollection<sqlceCheckDataParameter> z4sSqlceCheckDataParameters = target.z4sEntityProvider.GetSqlceCheckDataContext( new Guid( "A574EE4F-F614-46B9-9B4B-B505195C630D" ) ).sqlceCheckDataParameter;
            List<SqlceCheckDataParameter> expectedList = new List<SqlceCheckDataParameter>();
            SqlceCheckDataParameter expected = new SqlceCheckDataParameter()
            {
                sqlceCheckDataParameter_name = "sqlceCheckDataParameter_name",
                sqlceCheckDataParameter_sqlValueTypeEnum = SqlValueTypeEnum.Nvarchar,
                sqlceCheckDataParameter_value = Encoding.UTF8.GetBytes( "sqlceCheckDataParameterValue" )
            };
            expectedList.Add( expected );
            List<SqlceCheckDataParameter> actual;
            actual = target.ConvertToPOCO( z4sSqlceCheckDataParameters );
            Assert.AreEqual( expectedList[ 0 ].sqlceCheckDataParameter_name, actual[ 0 ].sqlceCheckDataParameter_name );
            Assert.AreEqual( expectedList[ 0 ].sqlceCheckDataParameter_sqlValueTypeEnum, actual[ 0 ].sqlceCheckDataParameter_sqlValueTypeEnum );
            Assert.AreEqual( expectedList[ 0 ].sqlceCheckDataParameter_value.Length, actual[ 0 ].sqlceCheckDataParameter_value.Length );
            for ( int i = 0 ; i < expectedList[ 0 ].sqlceCheckDataParameter_value.Length ; i++ )
            {
                Assert.IsTrue( actual[ 0 ].sqlceCheckDataParameter_value[ i ] == expectedList[ 0 ].sqlceCheckDataParameter_value[ i ] );
            }
        }
    
        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOSqlServerCheckDataParameterTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            EntityCollection<sqlServerCheckDataParameter> z4sSqlServerCheckDataParameters = target.z4sEntityProvider.GetSqlServerCheckDataContext( new Guid( "DFF6F7B3-1A3F-4FDE-A439-15BFD0EE0679" ) ).sqlServerCheckDataParameter;
            List<SqlServerCheckDataParameter> expectedList = new List<SqlServerCheckDataParameter>();
            SqlServerCheckDataParameter expected = new SqlServerCheckDataParameter()
            {
                sqlServerCheckDataParameter_name = "sqlServerCheckDataParameterName",
                sqlServerCheckDataParameter_sqlValueTypeEnum = SqlValueTypeEnum.Nvarchar,
                sqlServerCheckDataParameter_value = Encoding.UTF8.GetBytes( "sqlServerCheckDataParameterValue" )
            };

            expectedList.Add( expected );
            List<SqlServerCheckDataParameter> actual;
            actual = target.ConvertToPOCO( z4sSqlServerCheckDataParameters );
            Assert.AreEqual( expectedList[ 0 ].sqlServerCheckDataParameter_name, actual[ 0 ].sqlServerCheckDataParameter_name );
            Assert.AreEqual( expectedList[ 0 ].sqlServerCheckDataParameter_sqlValueTypeEnum, actual[ 0 ].sqlServerCheckDataParameter_sqlValueTypeEnum );
            Assert.AreEqual( expectedList[ 0 ].sqlServerCheckDataParameter_value.Length, actual[ 0 ].sqlServerCheckDataParameter_value.Length );
            for ( int i = 0 ; i < expectedList[ 0 ].sqlServerCheckDataParameter_value.Length ; i++ )
            {
                Assert.IsTrue( actual[ 0 ].sqlServerCheckDataParameter_value[ i ] == expectedList[ 0 ].sqlServerCheckDataParameter_value[ i ] );
            }
        }
         
        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOSqlServerExecutionParameterTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            EntityCollection<sqlServerExecutionParameter> z4sSqlServerExecutionParameters = target.z4sEntityProvider.GetSqlServerExecutionContext( new Guid( "22B3D012-7AC2-47BD-9D44-E76919F0C51A" ) ).sqlServerExecutionParameter;
            List<SqlServerExecutionParameter> expectedList = new List<SqlServerExecutionParameter>();
            SqlServerExecutionParameter expected = new SqlServerExecutionParameter()
            {
                sqlServerExecutionParameter_name = "sqlServerExecutionParameterName",
                sqlServerExecutionParameter_sqlValueTypeEnum = SqlValueTypeEnum.Int,
                sqlServerExecutionParameter_value = Encoding.ASCII.GetBytes( "sqlServerExecutionParameterValue" )
            };
            expectedList.Add( expected );
            List<SqlServerExecutionParameter> actual;
            actual = target.ConvertToPOCO( z4sSqlServerExecutionParameters );
            Assert.AreEqual( expectedList[ 0 ].sqlServerExecutionParameter_name, actual[ 0 ].sqlServerExecutionParameter_name );
            Assert.AreEqual( expectedList[ 0 ].sqlServerExecutionParameter_sqlValueTypeEnum, actual[ 0 ].sqlServerExecutionParameter_sqlValueTypeEnum );
            Assert.AreEqual( expectedList[ 0 ].sqlServerExecutionParameter_value.Length, actual[ 0 ].sqlServerExecutionParameter_value.Length );
            for ( int i = 0 ; i < expectedList[ 0 ].sqlServerExecutionParameter_value.Length ; i++ )
            {
                Assert.IsTrue( actual[ 0 ].sqlServerExecutionParameter_value[ i ] == expectedList[ 0 ].sqlServerExecutionParameter_value[ i ] );
            }
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOActivitiesTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            EntityCollection<activity> z4sActivities = GetTestScenario( new Guid( "F5062C6D-C6F2-4995-BFFB-37EC4B9AB442" ) ).activity;
            Activity expected = new Activity()
            {
                activity_id = new Guid( "68F62FA9-6872-45F1-8E89-5E31B1C634ED" ),
                activity_executionOrder = 2,
                activity_preWaitingTimeInSeconds = 0,
                activity_postWaitingTimeInSeconds = 0,
                activity_sqlCeExecution = target.POCOSqlceExecution( new Guid( "BE915A1D-191E-4766-B945-339F1F5E9574" ) ),
                activity_activityTypeEnum = Zen4SyncPOCO.POCO.Enum.Scenario.ActivityTypeEnum.SqlCeExecution,
            };

            List<Activity> actual;
            actual = target.ConvertToPOCO( z4sActivities,SymmetricKeyPassword );
            foreach ( Activity activity in actual )
            {
                if ( expected.activity_id == activity.activity_id )
                {
                    Assert.AreEqual( expected.activity_id, activity.activity_id );
                    Assert.AreEqual( expected.activity_executionOrder, activity.activity_executionOrder );
                    Assert.AreEqual( expected.activity_preWaitingTimeInSeconds, activity.activity_preWaitingTimeInSeconds );
                    Assert.AreEqual( expected.activity_sqlCeExecution, activity.activity_sqlCeExecution );
                    Assert.AreEqual( expected.activity_activityTypeEnum, activity.activity_activityTypeEnum );
                    break;
                }
            }
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOSqlceExecutionParameterTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            EntityCollection<sqlceExecutionParameter> z4sSqlceExecutionParameters = target.z4sEntityProvider.GetSqlceExecutionContext( new Guid( "B61D4C74-3CA4-4AE4-BECB-34B1818236FD" ) ).sqlceExecutionParameter;
            List<SqlceExecutionParameter> expectedList = new List<SqlceExecutionParameter>();
            SqlceExecutionParameter expected = new SqlceExecutionParameter()
            {
                sqlceExecutionParameter_name = "sqlceExecutionParameterName",
                sqlceExecutionParameter_value = Encoding.ASCII.GetBytes( "sqlceExecutionParameterValue" ),
                sqlceExecutionParameter_sqlValueTypeEnum = SqlValueTypeEnum.Int
            };
            expectedList.Add( expected );
            List<SqlceExecutionParameter> actual;
            actual = target.ConvertToPOCO( z4sSqlceExecutionParameters );
            Assert.AreEqual( expectedList[ 0 ].sqlceExecutionParameter_name, actual[ 0 ].sqlceExecutionParameter_name );
            Assert.AreEqual( expectedList[ 0 ].sqlceExecutionParameter_sqlValueTypeEnum, actual[ 0 ].sqlceExecutionParameter_sqlValueTypeEnum );
            Assert.AreEqual( expectedList[ 0 ].sqlceExecutionParameter_value.Length, actual[ 0 ].sqlceExecutionParameter_value.Length );
            for ( int i = 0 ; i < expectedList[ 0 ].sqlceExecutionParameter_value.Length ; i++ )
            {
                Assert.IsTrue( actual[ 0 ].sqlceExecutionParameter_value[ i ] == expectedList[ 0 ].sqlceExecutionParameter_value[ i ] );
            }
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOActivityTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            activity z4sActivity = target.z4sEntityProvider.GetActivity( new Guid( "68F62FA9-6872-45F1-8E89-5E31B1C634ED" ) );
            Activity expected = new Activity()
            {
                activity_id = new Guid( "68F62FA9-6872-45F1-8E89-5E31B1C634ED" ),
                activity_executionOrder = 2,
                activity_preWaitingTimeInSeconds = 0,
                activity_postWaitingTimeInSeconds = 0,
                activity_sqlCeExecution = target.POCOSqlceExecution( new Guid( "BE915A1D-191E-4766-B945-339F1F5E9574" ) ),
                activity_activityTypeEnum = Zen4SyncPOCO.POCO.Enum.Scenario.ActivityTypeEnum.SqlCeExecution,
            };
            Activity actual;
            actual = target.ConvertToPOCO( z4sActivity,SymmetricKeyPassword );
            Assert.AreEqual( expected.activity_id, actual.activity_id );
            Assert.AreEqual( expected.activity_executionOrder, actual.activity_executionOrder );
            Assert.AreEqual( expected.activity_preWaitingTimeInSeconds, actual.activity_preWaitingTimeInSeconds );
            Assert.AreEqual( expected.activity_sqlCeExecution.sqlceExecution_id, actual.activity_sqlCeExecution.sqlceExecution_id );
            Assert.AreEqual( expected.activity_activityTypeEnum, actual.activity_activityTypeEnum );
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOTestScenarioTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            testScenario z4sTestScenario = GetTestScenario( new Guid( "F5062C6D-C6F2-4995-BFFB-37EC4B9AB442" ) );
            TestScenario expected = new TestScenario()
            {
                testScenario_id = new Guid( "F5062C6D-C6F2-4995-BFFB-37EC4B9AB442" ),
                testScenario_activities = target.ConvertToPOCO( z4sTestScenario.activity,SymmetricKeyPassword )
            };

            Activity expectedActivity = new Activity()
            {
                activity_id = new Guid( "1275E750-951D-4F31-A1A4-1E9CF5A4D722" ),
                activity_executionOrder = 1,
                activity_preWaitingTimeInSeconds = 0,
                activity_postWaitingTimeInSeconds = 0,
                activity_sqlCeBackup = target.POCOSqlceBackup( new Guid( "9F0F8A74-6F59-41EF-A283-E0C8409C57AD" ) ),
                activity_activityTypeEnum = Zen4SyncPOCO.POCO.Enum.Scenario.ActivityTypeEnum.SqlCeBackup,
            };

            TestScenario actual;
            actual = target.ConvertToPOCO( z4sTestScenario,SymmetricKeyPassword );
            Assert.AreEqual( expected.testScenario_id, actual.testScenario_id );

            foreach ( Activity activity in actual.testScenario_activities )
            {
                if ( expectedActivity.activity_id == activity.activity_id )
                {
                    Assert.AreEqual( expectedActivity.activity_id, activity.activity_id );
                    break;
                }
            }
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOActivityContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            EntityCollection<activityContext> z4sActivityContexts = GetClientSession( new Guid( "87843D09-C873-45DA-8E0E-B66A30D719A6" ) ).activityContext;
            List<Activity> activities = target.ConvertToPOCO( GetTestScenario( new Guid( "F5062C6D-C6F2-4995-BFFB-37EC4B9AB442" ) ).activity, SymmetricKeyPassword );
            ActivityContext expected = new ActivityContext()
            {
                activityContext_id = new Guid( "B8DADA4D-D23D-4D5F-88B0-FE291CD1644D" ),
                activityContext_activityId = new Guid( "F42DE5E1-C050-40AF-B2CB-8A02F06BFA28" ),
                activityContext_overridingData = "overridingData.xml",
                activityContext_sqlServerCheckDataContext = target.POCOsqlServerCheckDataContext( new Guid( "DFF6F7B3-1A3F-4FDE-A439-15BFD0EE0679" ),SymmetricKeyPassword )
            };
            List<ActivityContext> actual;
            actual = target.ConvertToPOCO( z4sActivityContexts, activities,SymmetricKeyPassword );
            foreach ( ActivityContext aContext in actual )
            {
                if ( expected.activityContext_id == aContext.activityContext_id )
                {
                    Assert.AreEqual( expected.activityContext_id, aContext.activityContext_id );
                    Assert.AreEqual( expected.activityContext_activityId, aContext.activityContext_activityId );
                    Assert.AreEqual( expected.activityContext_overridingData, aContext.activityContext_overridingData );
                    Assert.AreEqual( expected.activityContext_sqlServerCheckDataContext.sqlServerCheckDataContext_id, aContext.activityContext_sqlServerCheckDataContext.sqlServerCheckDataContext_id );
                    break;
                }
            }
        }

  /*TODO      /// <summary>                                                                             
        ///Test pour POCOMefExecution
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOMefExecutionTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid mefExecutionId = new Guid( "9774766B-F49A-46B9-870A-8203D7F04B1C" );
            MefExecution expected = new MefExecution()
            {
                mefExecution_id = mefExecutionId,
                mefExecution_metadata = "metadata.xml"
            };
            MefExecution actual;
            actual = target.POCOMefExecution( mefExecutionId );
            Assert.AreEqual( expected.mefExecution_id, actual.mefExecution_id );
            Assert.AreEqual( expected.mefExecution_metadata, actual.mefExecution_metadata );   
        }  */                                                                                                  
        
        /// <summary>
        ///Test pour POCOMefExecutionContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOMefExecutionContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid mefExecutionContextId = new Guid( "40D9B3A2-A775-4404-83D0-8E630CB1CEB6" );
            MefExecutionContext expected = new MefExecutionContext()
            {
                mefExecutionContext_id = mefExecutionContextId,
                mefExecutionContext_metadata = "metadata.xml"
            };
            MefExecutionContext actual;
            actual = target.POCOMefExecutionContext( mefExecutionContextId );
            Assert.AreEqual( expected.mefExecutionContext_id, actual.mefExecutionContext_id );
            Assert.AreEqual( expected.mefExecutionContext_metadata, actual.mefExecutionContext_metadata );
        }
                         
        /// <summary>
        ///Test pour POCOSqlServerCheckData
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSqlServerCheckDataTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlServerCheckDataId = new Guid( "29FC5A45-F0F1-41AC-9E49-FC8AAB7827FE" );
            SqlServerCheckData expected = new SqlServerCheckData()
            {
                sqlServerCheckData_id = sqlServerCheckDataId,
                sqlServerCheckData_sqlQuery = "sqlQuery,",
                sqlServerCheckData_expectedValue = Encoding.ASCII.GetBytes( "expectedValue" ),
                sqlServerCheckData_sqlValueTypeEnum = SqlValueTypeEnum.Nvarchar

            };
            SqlServerCheckData actual;
            actual = target.POCOSqlServerCheckData( sqlServerCheckDataId );
            Assert.AreEqual( expected.sqlServerCheckData_id, actual.sqlServerCheckData_id );
            Assert.AreEqual( expected.sqlServerCheckData_sqlQuery, actual.sqlServerCheckData_sqlQuery );
            for ( int i = 0 ; i < expected.sqlServerCheckData_expectedValue.Length ; i++ )
            {
                Assert.IsTrue( actual.sqlServerCheckData_expectedValue[ i ] == expected.sqlServerCheckData_expectedValue[ i ] );
            }
            Assert.AreEqual( expected.sqlServerCheckData_sqlValueTypeEnum, actual.sqlServerCheckData_sqlValueTypeEnum );
        }

        /// <summary>
        ///Test pour POCOSqlceBackup
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSqlceBackupTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlceBackupId = new Guid( "9F0F8A74-6F59-41EF-A283-E0C8409C57AD" );
            SqlceBackup expected = new SqlceBackup()
            {
                sqlceBackup_id = sqlceBackupId
            };
            SqlceBackup actual;
            actual = target.POCOSqlceBackup( sqlceBackupId );
            Assert.AreEqual( expected.sqlceBackup_id, actual.sqlceBackup_id );
        }

        /// <summary>
        ///Test pour POCOSqlceCheckData
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSqlceCheckDataTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlceCheckDataId = new Guid( "10B76474-A7B8-42B9-9A04-501E9E917018" );
            SqlceCheckData expected = new SqlceCheckData()
            {
                sqlceCheckData_id = sqlceCheckDataId,
                sqlceCheckData_sqlQuery = "sqlQuery",
                sqlceCheckData_sqlValueTypeEnum = SqlValueTypeEnum.Nvarchar,
                sqlceCheckData_expectedValue = Encoding.ASCII.GetBytes( "expectedValue" ),
            };

            SqlceCheckData actual;
            actual = target.POCOSqlceCheckData( sqlceCheckDataId );
            Assert.AreEqual( expected.sqlceCheckData_id, actual.sqlceCheckData_id );
            Assert.AreEqual( expected.sqlceCheckData_sqlQuery, actual.sqlceCheckData_sqlQuery );
            Assert.AreEqual( expected.sqlceCheckData_sqlValueTypeEnum, actual.sqlceCheckData_sqlValueTypeEnum );
            for ( int i = 0 ; i < expected.sqlceCheckData_expectedValue.Length ; i++ )
            {
                Assert.IsTrue( actual.sqlceCheckData_expectedValue[ i ] == expected.sqlceCheckData_expectedValue[ i ] );
            }
        }

        /// <summary>
        ///Test pour POCOSqlceExecution
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSqlceExecutionTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlceExecutionId = new Guid( "BE915A1D-191E-4766-B945-339F1F5E9574" );
            SqlceExecution expected = new SqlceExecution()
            {
                sqlceExecution_id = sqlceExecutionId,
                sqlceExecution_sqlQuery = "sqlceExecutionSqlQuery"
            };
            SqlceExecution actual;
            actual = target.POCOSqlceExecution( sqlceExecutionId );
            Assert.AreEqual( expected.sqlceExecution_id, actual.sqlceExecution_id );
            Assert.AreEqual( expected.sqlceExecution_sqlQuery, actual.sqlceExecution_sqlQuery );
        }

        /// <summary>
        ///Test pour POCOSyncSession
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSyncSessionTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid syncSessionId = new Guid( "2B2BE227-2C90-42F8-9332-B3219C848B97" );
            SyncSession expected = new SyncSession()
            {
                syncSession_id = syncSessionId,
                syncSession_compressionLevel = 1,
                syncSession_connectionRetryTimeout = 120,
                syncSession_connectTimeout = 0,
                syncSession_hostName = "hostName",
                syncSession_loginTimeout = 15,
                syncSession_postSyncCleanup = 0,
                syncSession_publication = "publication",
                syncSession_queryTimeout = 300,
                syncSession_receiveTimeout = 60000,
                syncSession_sendTimeout = 0,
                syncSession_exchangeTypeEnum = ExchangeTypeEnum.BiDirectional,
                syncSession_snapshotTransferTypeEnum = SnapshotTransfertTypeEnum.UNC,
                syncSession_distributor = target.POCOSyncSession( syncSessionId,SymmetricKeyPassword ).syncSession_distributor,
                syncSession_publisher = target.POCOSyncSession( syncSessionId,SymmetricKeyPassword ).syncSession_publisher,
                syncSession_internet = target.POCOSyncSession( syncSessionId,SymmetricKeyPassword ).syncSession_internet
            };
            SyncSession actual;
            actual = target.POCOSyncSession( syncSessionId,SymmetricKeyPassword );
            Assert.AreEqual( expected.syncSession_id, actual.syncSession_id );
            Assert.AreEqual( expected.syncSession_compressionLevel, actual.syncSession_compressionLevel );
            Assert.AreEqual( expected.syncSession_connectionRetryTimeout, actual.syncSession_connectionRetryTimeout );
            Assert.AreEqual( expected.syncSession_connectTimeout, actual.syncSession_connectTimeout );
            Assert.AreEqual( expected.syncSession_hostName, actual.syncSession_hostName );
            Assert.AreEqual( expected.syncSession_loginTimeout, actual.syncSession_loginTimeout );
            Assert.AreEqual( expected.syncSession_postSyncCleanup, actual.syncSession_postSyncCleanup );
            Assert.AreEqual( expected.syncSession_publication, actual.syncSession_publication );
            Assert.AreEqual( expected.syncSession_queryTimeout, actual.syncSession_queryTimeout );
            Assert.AreEqual( expected.syncSession_receiveTimeout, actual.syncSession_receiveTimeout );
            Assert.AreEqual( expected.syncSession_sendTimeout, actual.syncSession_sendTimeout );
            Assert.AreEqual( expected.syncSession_exchangeTypeEnum, actual.syncSession_exchangeTypeEnum );
            Assert.AreEqual( expected.syncSession_snapshotTransferTypeEnum, actual.syncSession_snapshotTransferTypeEnum );
            Assert.AreEqual( expected.syncSession_distributor.distributor_id, actual.syncSession_distributor.distributor_id );
            Assert.AreEqual( expected.syncSession_publisher.publisher_id, actual.syncSession_publisher.publisher_id );
            Assert.AreEqual( expected.syncSession_internet.internet_id, actual.syncSession_internet.internet_id );
        }

        /// <summary>
        ///Test pour POCOSyncSessionContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOSyncSessionContextTest()
        { 
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid syncSessionContextId = new Guid( "823A1687-11B0-426F-BD08-0827B4AFD64D" );
            SyncSessionContext expected = new SyncSessionContext()
            {
                syncSessionContext_id = syncSessionContextId,
                syncSessionContext_subscriber = new Subscriber()
                {
                    subscriber_id = new Guid( "C25573CB-1D1F-458A-88F4-AB4AB4F952B9" )
                }
            };

            SyncSessionContext actual;
            actual = target.POCOSyncSessionContext( syncSessionContextId );
            Assert.AreEqual( expected.syncSessionContext_id, actual.syncSessionContext_id );
            Assert.AreEqual( expected.syncSessionContext_subscriber.subscriber_id, actual.syncSessionContext_subscriber.subscriber_id );
        }

        /// <summary>
        ///Test pour POCOsqlCeBackupContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOsqlCeBackupContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlceBackupContextId = new Guid( "C3644FD9-EBEE-492E-89F7-74F468BCE6D5" );
            SqlceBackupContext expected = new SqlceBackupContext()
            {
                sqlceBackupContext_id = sqlceBackupContextId,
                sqlceBackupContext_sdfFileDirectory = "sdfFileDirectory",
                sqlceBackupContext_sdfFileName = "sdfFileName"
            };
            SqlceBackupContext actual;
            actual = target.POCOsqlCeBackupContext( sqlceBackupContextId );
            Assert.AreEqual( expected.sqlceBackupContext_id, actual.sqlceBackupContext_id );
            Assert.AreEqual( expected.sqlceBackupContext_sdfFileDirectory, actual.sqlceBackupContext_sdfFileDirectory );
            Assert.AreEqual( expected.sqlceBackupContext_sdfFileName, actual.sqlceBackupContext_sdfFileName );
        }
       
        /// <summary>
        ///Test pour POCOsqlCeCheckDataContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOsqlCeCheckDataContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlceCheckDataContextId = new Guid( "A574EE4F-F614-46B9-9B4B-B505195C630D" );
            SqlceCheckDataContext expected = new SqlceCheckDataContext()
            {
                sqlceCheckDataContext_id = sqlceCheckDataContextId,
                sqlceCheckDataContext_parameters = target.ConvertToPOCO( target.z4sEntityProvider.GetSqlceCheckDataContext( sqlceCheckDataContextId ).sqlceCheckDataParameter ),
                sqlceCheckDataContext_connectionString = "connect cdc"

            };
            SqlceCheckDataContext actual;
            actual = target.POCOsqlCeCheckDataContext( sqlceCheckDataContextId,SymmetricKeyPassword );
            Assert.AreEqual( expected.sqlceCheckDataContext_id, actual.sqlceCheckDataContext_id );
            Assert.AreEqual( expected.sqlceCheckDataContext_parameters[ 0 ].sqlceCheckDataParameter_name, actual.sqlceCheckDataContext_parameters[ 0 ].sqlceCheckDataParameter_name );
            Assert.AreEqual( expected.sqlceCheckDataContext_connectionString, actual.sqlceCheckDataContext_connectionString );
        }
      
        /// <summary>
        ///Test pour POCOsqlCeExecutionContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOsqlCeExecutionContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlCeExecutionContextId = new Guid( "B61D4C74-3CA4-4AE4-BECB-34B1818236FD" );
            SqlceExecutionContext expected = new SqlceExecutionContext()
            {
                sqlceExecutionContext_id = sqlCeExecutionContextId,
                sqlceExecutionContext_parameters = target.ConvertToPOCO( target.z4sEntityProvider.GetSqlceExecutionContext( sqlCeExecutionContextId ).sqlceExecutionParameter ),
                sqlCeExecutionContext_connectionString="connect cec"

            };
            SqlceExecutionContext actual;
            actual = target.POCOsqlCeExecutionContext( sqlCeExecutionContextId,SymmetricKeyPassword );
            Assert.AreEqual( expected.sqlceExecutionContext_id, actual.sqlceExecutionContext_id );
            Assert.AreEqual( expected.sqlceExecutionContext_parameters[ 0 ].sqlceExecutionParameter_name, actual.sqlceExecutionContext_parameters[ 0 ].sqlceExecutionParameter_name );
            Assert.AreEqual( expected.sqlCeExecutionContext_connectionString, actual.sqlCeExecutionContext_connectionString );
        }
        
        /// <summary>
        ///Test pour POCOsqlServerCheckDataContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOsqlServerCheckDataContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlServerCheckDataContextId = new Guid( "DFF6F7B3-1A3F-4FDE-A439-15BFD0EE0679" );
            SqlServerCheckDataContext expected = new SqlServerCheckDataContext()
            {
                sqlServerCheckDataContext_id = sqlServerCheckDataContextId,
                sqlServerCheckDataContext_parameters = target.ConvertToPOCO( target.z4sEntityProvider.GetSqlServerCheckDataContext( sqlServerCheckDataContextId ).sqlServerCheckDataParameter ),
                sqlServerCheckDataContext_connectionString="connect cd"

            };
            SqlServerCheckDataContext actual;
            actual = target.POCOsqlServerCheckDataContext( sqlServerCheckDataContextId,SymmetricKeyPassword );
            Assert.AreEqual( expected.sqlServerCheckDataContext_id, actual.sqlServerCheckDataContext_id );
            Assert.AreEqual( expected.sqlServerCheckDataContext_parameters[ 0 ].sqlServerCheckDataParameter_name, actual.sqlServerCheckDataContext_parameters[ 0 ].sqlServerCheckDataParameter_name );
          Assert.AreEqual( expected.sqlServerCheckDataContext_connectionString, actual.sqlServerCheckDataContext_connectionString );
        }
         
        /// <summary>
        ///Test pour POCOsqlServerExecutionContext
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void POCOsqlServerExecutionContextTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            Guid sqlServerExecutionContextId = new Guid( "22B3D012-7AC2-47BD-9D44-E76919F0C51A" );
            SqlServerExecutionContext expected = new SqlServerExecutionContext()
            {
                sqlServerExecutionContext_id = sqlServerExecutionContextId,
                sqlServerExecutionContext_parameters = target.ConvertToPOCO( target.z4sEntityProvider.GetSqlServerExecutionContext( sqlServerExecutionContextId ).sqlServerExecutionParameter ),
                sqlServerExecutionContext_connectionString = "connect sec"

            };
            SqlServerExecutionContext actual;
            actual = target.POCOsqlServerExecutionContext( sqlServerExecutionContextId,SymmetricKeyPassword );
            Assert.AreEqual( expected.sqlServerExecutionContext_id, actual.sqlServerExecutionContext_id );
            Assert.AreEqual( expected.sqlServerExecutionContext_parameters[ 0 ].sqlServerExecutionParameter_name, actual.sqlServerExecutionContext_parameters[ 0 ].sqlServerExecutionParameter_name );
          Assert.AreEqual( expected.sqlServerExecutionContext_connectionString, actual.sqlServerExecutionContext_connectionString );
        }

        /// <summary>
        ///Test pour ConvertToEntity
        ///</summary>
        [TestMethod()]
        public void ConvertToEntitySqlServerExecutionContextTest()
        {
            ModelConverter target = new ModelConverter();
            SqlServerExecutionContext sqlServerExecutionContextPOCO = new SqlServerExecutionContext()
            {
                sqlServerExecutionContext_id = new Guid( "22B3D012-7AC2-47BD-9D44-E76919F0C51A" ),
                sqlServerExecutionContext_parameters = new List<SqlServerExecutionParameter>()
                {
                    new SqlServerExecutionParameter(){
                    sqlServerExecutionParameter_name="sqlServerExecutionParameterName",
                    sqlServerExecutionParameter_value=Encoding.ASCII.GetBytes("sqlServerExecutionParameterValue"),
                    sqlServerExecutionParameter_sqlValueTypeEnum = SqlValueTypeEnum.Int
                    }
                }
            };
            sqlServerExecutionContext expected;
            using ( Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities() )
            {
                expected = z4sEntities.sqlServerExecutionContext.Include( "sqlServerExecutionParameter" )
                    .Where( sql => sql.sqlServerExecutionContext_id == new Guid( "22B3D012-7AC2-47BD-9D44-E76919F0C51A" ) ).Single();
            }
            sqlServerExecutionContext actual;
            actual = target.ConvertToEntity( sqlServerExecutionContextPOCO );
            Assert.AreEqual( expected.sqlServerExecutionContext_id, actual.sqlServerExecutionContext_id );
            Assert.AreEqual( expected.sqlServerExecutionParameter.Count, actual.sqlServerExecutionParameter.Count );
            foreach ( sqlServerExecutionParameter parameterActual in actual.sqlServerExecutionParameter )
            {
                foreach ( sqlServerExecutionParameter parameterExpected in expected.sqlServerExecutionParameter )
                {
                    if ( parameterExpected.sqlServerExecutionParameter_name == parameterActual.sqlServerExecutionParameter_name )
                    {
                        Assert.AreEqual( parameterExpected.sqlServerExecutionParameter_sqlValueTypeId, parameterActual.sqlServerExecutionParameter_sqlValueTypeId );
                        Assert.AreEqual( parameterExpected.sqlServerExecutionParameter_value.Length, parameterActual.sqlServerExecutionParameter_value.Length );
                        for ( int i = 0 ; i < parameterActual.sqlServerExecutionParameter_value.Length ; i++ )
                        {
                            Assert.IsTrue( parameterExpected.sqlServerExecutionParameter_value[ i ] == parameterActual.sqlServerExecutionParameter_value[ i ] );
                        }
                        break;
                    }
                }
            }
        }

        /// <summary>
        ///Test pour ConvertToEntity
        ///</summary>
        [TestMethod()]
        public void ConvertToEntitySqlceExecutionContextTest()
        {
            ModelConverter target = new ModelConverter();
            SqlceExecutionContext sqlceExecutionContextPOCO = new SqlceExecutionContext()
            {
                sqlceExecutionContext_id = new Guid( "B61D4C74-3CA4-4AE4-BECB-34B1818236FD" ),
                sqlceExecutionContext_parameters = new List<SqlceExecutionParameter>()
                {
                    new SqlceExecutionParameter(){
                    sqlceExecutionParameter_name="sqlceExecutionParameterName",
                    sqlceExecutionParameter_value=Encoding.ASCII.GetBytes("sqlceExecutionParameterValue"),
                    sqlceExecutionParameter_sqlValueTypeEnum = SqlValueTypeEnum.Int
                    }
                }
            };
            sqlceExecutionContext expected;
            using ( Zen4SyncRepositoryEntities z4sEntities = new Zen4SyncRepositoryEntities() )
            {
                expected = z4sEntities.sqlceExecutionContext.Include( "sqlceExecutionParameter" )
                    .Where( sql => sql.sqlceExecutionContext_id == new Guid( "B61D4C74-3CA4-4AE4-BECB-34B1818236FD" ) ).Single();
            }
            sqlceExecutionContext actual;
            actual = target.ConvertToEntity( sqlceExecutionContextPOCO );
            Assert.AreEqual( expected.sqlceExecutionContext_id, actual.sqlceExecutionContext_id );
            Assert.AreEqual( expected.sqlceExecutionParameter.Count, actual.sqlceExecutionParameter.Count );
            foreach ( sqlceExecutionParameter parameterActual in actual.sqlceExecutionParameter )
            {
                foreach ( sqlceExecutionParameter parameterExpected in expected.sqlceExecutionParameter )
                {
                    if ( parameterExpected.sqlceExecutionParameter_name == parameterActual.sqlceExecutionParameter_name )
                    {
                        Assert.AreEqual( parameterExpected.sqlceExecutionParameter_sqlValueTypeId, parameterActual.sqlceExecutionParameter_sqlValueTypeId );
                        Assert.AreEqual( parameterExpected.sqlceExecutionParameter_value.Length, parameterActual.sqlceExecutionParameter_value.Length );
                        for ( int i = 0 ; i < parameterActual.sqlceExecutionParameter_value.Length ; i++ )
                        {
                            Assert.IsTrue( parameterExpected.sqlceExecutionParameter_value[ i ] == parameterActual.sqlceExecutionParameter_value[ i ] );
                        }
                        break;
                    }
                }
            }
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOTestServerTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            testServer z4sTestServer = target.z4sEntityProvider.GetTestServer( new Guid( "4C439FF8-EE20-46C8-959A-250170B231F6" ) );
            TestServer expected = new TestServer()
            {
                testServer_id = new Guid( "4C439FF8-EE20-46C8-959A-250170B231F6" ),
                testServer_hostName = "TestServerHostName_1",
                testServer_wcfConfigSectionName = "TestServerwcfConfigSectionName_1",
                testServer_loadSyncApplicationPath = "TestServerloadSyncApplicationPath_1",
                testServer_configFilesDirectory = "TestServerconfigFilesDirectory_1"
            };
            TestServer actual;
            actual = target.ConvertToPOCO( z4sTestServer );
            Assert.AreEqual( expected.testServer_id, actual.testServer_id );
            Assert.AreEqual( expected.testServer_hostName, actual.testServer_hostName );
            Assert.AreEqual( expected.testServer_wcfConfigSectionName, actual.testServer_wcfConfigSectionName );
            Assert.AreEqual( expected.testServer_loadSyncApplicationPath, actual.testServer_loadSyncApplicationPath );
            Assert.AreEqual( expected.testServer_configFilesDirectory, actual.testServer_configFilesDirectory );
        }

        /// <summary>
        ///Test pour ConvertToPOCO
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Zen4SyncOrchestrator.dll" )]
        public void ConvertToPOCOClientSessionTest()
        {
            ModelConverter_Accessor target = new ModelConverter_Accessor();
            clientSession z4sClientSession = GetClientSession(new Guid("87843D09-C873-45DA-8E0E-B66A30D719A6"));
            ClientSession expected = new ClientSession()
            {
                clientSession_id = z4sClientSession.clientSession_id,
                clientSession_testServerId = z4sClientSession.clientSession_testServerId,
                clientSession_testSessionId = z4sClientSession.clientSession_testSessionId,
                clientSession_enableLog = z4sClientSession.clientSession_enableLog,
                clientSession_scheduledStartDateTime = z4sClientSession.clientSession_scheduledStartDateTime,
                clientSession_testScenario = target.ConvertToPOCO( z4sClientSession.testScenario, SymmetricKeyPassword ),
            };
            expected.clientSession_activityContexts = target.ConvertToPOCO( z4sClientSession.activityContext, expected.clientSession_testScenario.testScenario_activities, SymmetricKeyPassword );
            ClientSession actual;
            actual = target.ConvertToPOCO( z4sClientSession, SymmetricKeyPassword );
            Assert.AreEqual(expected.clientSession_id, actual.clientSession_id);
            Assert.AreEqual(expected.clientSession_testServerId, actual.clientSession_testServerId);
            Assert.AreEqual(expected.clientSession_testSessionId, actual.clientSession_testSessionId);
            Assert.AreEqual(expected.clientSession_enableLog, actual.clientSession_enableLog);
            Assert.AreEqual(expected.clientSession_scheduledStartDateTime, actual.clientSession_scheduledStartDateTime);
            Assert.AreEqual(expected.clientSession_testScenario.testScenario_id, actual.clientSession_testScenario.testScenario_id);
            Assert.AreEqual(expected.clientSession_activityContexts.Count, actual.clientSession_activityContexts.Count);
        }     
    }
}


